<?php
$this->pageTitle=Yii::app()->name . ' - Newsletter Sign Up';
$this->breadcrumbs=array(
	'Newsletter Sign Up',
);
?>

<div class="col-md-12 pb-50 pt-50 text-center banner" >
	<div class="wrapper">
		<img src="<?php echo Yii::app()->getBaseUrl();?>/images/newsletter-icon.png" />
		<h1 class="headings text-black">Newsletter Sign Up</h1>
	</div>
</div>

<div class="clearfix"></div>

<div class="wrapper">
	<div class="col-md-12 pt-20">
		<?php 
			$this->widget('zii.widgets.CBreadcrumbs', array(
		    	'links'=>array('Newsletter Sign Up'),
			));
		?>
	</div>
	<div class="clearfix"></div>
	
	<div class="col-md-12 pb-50 pt-40">
		<div class="col-md-8 row">
		
		
		<?php
			if ( isset(Yii::app()->user->model) && !empty(Yii::app()->user->model)){
				$model = Yii::app()->user->model;
				$extrafields = $model->name .' | '.$model->email .' | '.$model->company .' | '.$_SERVER['REMOTE_ADDR'];
				$this->renderPartial('site/salesforce', array('model'=>$model, 'extrafields' => $extrafields, 'newsletter'=>true));
				Yii::app()->user->setState('model',null);
			} else {
		
		?>
		
		
		<div class="ajax-loader pb-50 text-center"></div>
		<?php $form=$this->beginWidget('CActiveForm', array(
						'action' => $this->createUrl('site/signup'),
						'id'=>'user-form',
						'enableAjaxValidation'=>true,
						'clientOptions'=>array(
					      'validateOnSubmit'=>true,
					     ),
				
					)); 
		?>
		
			<p class="note">Lake B2B is a leader in data management services, list solutions, and customer data insights. Sign up for our newsletter for latest trends and insights on data-driven marketing</p>
		
		
			<div class="form-group col-md-12 row">
				<?php echo $form->labelEx($model,'name', array('for'=>'contact_name')); ?>
				<?php echo $form->textField($model,'name', array('class'=>'form-control', 'placeholder'=>'Full Name', 'id'=>'contact_name')); ?>
				<?php echo $form->error($model,'name'); ?>
			</div>
		
			<div class="form-group col-md-12 row">
				<?php echo $form->labelEx($model,'email', array('for'=>'contact_email')); ?>
				<?php echo $form->textField($model,'email', array('class'=>'form-control', 'placeholder'=>'Email Address*', 'id'=>'contact_email')); ?>
				<?php echo $form->error($model,'email'); ?>
			</div>
		
			<div class="form-group col-md-12 row">
				<?php echo $form->labelEx($model,'company', array('for'=>'contact_company')); ?>
				<?php echo $form->textField($model,'company', array('class'=>'form-control', 'placeholder'=>'Company Name', 'id'=>'contact_mobile')); ?>
				<?php echo $form->error($model,'company'); ?>
			</div>
		
			<div class="form-group col-md-12 row">
				<div class="col-md-4 row">
				<?php echo CHtml::ajaxSubmitButton('Get Newsletters', Yii::app()->getBaseUrl().'/site/signup/',
                 array(
                     'dataType'=>'json',
                     'type'=>'post',
                     'success'=>'function(data) {
                        if(data.status=="success"){
                 		 $(".ajax-loader").show();
                         //$(".ajax-loader").html("<h3 class=headings>Thank you</h3><p>Thank you for showing interest in Lake B2B services. One of our business development executives will contact you shortly to provide further information.</p>");
                         $("#user-form")[0].reset();
                 		 window.location = "'.$this->createUrl('site/signup').'/thanks/";
                        }
                         else{
                        $.each(data, function(key, val) {
                        $("#user-form #"+key+"_em_").text(val);                                                    
                        $("#user-form #"+key+"_em_").show();
                 		$("#user-form #"+key+"_em_").closest(".form-group").addClass("has-error");
                        });
                 		$(".ajax-loader").empty();
                        }       
                    }',
                 	'error' => 'function(data){
                 		$(".ajax-loader").html("Oops, please try after some time");
                 	}',
                     'beforeSend'=>'function(){
						$(".form-group").removeClass("has-error");
                 		$(".errorMessage").text("");
                        $(".ajax-loader").html("<img src='.Yii::app()->getBaseUrl().'/images/loading.gif alt=loading... />");
                      }'
                     ),array('id'=>'contactUs','class'=>'btn btn-danger')); ?>
                     
                   </div>  
                    
			</div>
			<div class="col-md-12 row form-group"><small><a href="<?php echo $this->createUrl('site/page', array('slug'=>'privacy-policy'))?>">Your privacy is important to us</a></small></div>
		<?php $this->endWidget(); ?>
		<?php } ?>
		</div><!-- form -->

	
	<!-- right column starts -->
	
		<?php $this->renderPartial('site/_rightbar')?>
		
	<!-- right column Ends -->
	</div>
</div>
<div class="clearfix"></div>
	<hr />
<!-- 3 blocks sectino with image starts  -->
	<?php $this->renderPartial('site/_blocks');?>
<!-- 3 blocks sectino with image Ends -->

<div class="clearfix"></div>

<!--  Newsletter section starts -->
<?php $this->renderPartial('site/_newsletter');?>
<!--  Newsletter section ends -->

<script>
$(document).ready(function(){
	$('.banner').animate({backgroundColor: "#fcd87f"}, 1000 );
	$('.banner img').animate({opacity :'1'}, 'slow');
	$('.banner .headings').animate({fontSize :'-=34px'},'slow');
});
</script>
<style>

.white-panel{
	box-shadow:none;
	min-height:100px;
	padding:0px;
}

.banner .headings{
	font-size:72px;
}
.banner img{
	opacity:.1;
}
</style>